//go:build windows

package encsdk

import (
	"gitee.com/fhe-search/fhe-search-rpc/encsdk/softsdk"
)

var (
	pEncryptType string
)

func SetEncryptType(encryptType string) {
	pEncryptType = encryptType
}

func EncInit(secretKeyBasePath string) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	softsdk.SoftEncInit(secretKeyBasePath)
}

func SymEncUtf8(utf8ClearText string) ([]byte, error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.AesEncUtf8(utf8ClearText)
}

func SymDecUtf8(utf8EncText []byte) (string, error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.AesDecUtf8(utf8EncText)
}

func SymEncS32Ex(int32Arr []int32) ([][]byte, error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.AesEncS32Ex(int32Arr)
}

func SymEncS32(plain int32) ([]byte, error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.AesEncS32(plain)
}

func SymDecS32(encData []byte) (int32, error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.AesDecS32(encData)
}

func FheEncUtf8(utf8Text string) ([]byte, error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.FheSoftEncUtf8(utf8Text)
}

func FheDecUtf8(utf8EncText []byte) (string, error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.FheSoftDecUtf8(utf8EncText)
}

func FheSub(enc1, enc2 []byte) (diff []byte, err error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.FheSoftSub(enc1, enc2)
}

func FheDecDiff(diff []byte) (bool, error) {
	if pEncryptType != "soft_encrypt" {
		panic("pEncryptType must be 'soft_encrypt' in windows os, but you give " + pEncryptType)
	}
	return softsdk.FheSoftDecDiff(diff)
}
